package com.dragon.im.service.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.dragon.im.mapper.ImOrderTrackingMapper;
import com.dragon.im.pojo.ImOrderTracking;
import com.dragon.im.pojo.ImOrderTrackingExample;
import com.dragon.im.pojo.ImOrderTrackingExample.Criteria;
import com.dragon.im.service.OrderTrackingService;
import com.dragon.im.util.Result;

public class OrderTrackingServiceImpl implements OrderTrackingService {
	@Autowired
	ImOrderTrackingMapper iotMapper;

	@Override
	public Result add(ImOrderTracking imOrderTracking) {
		ImOrderTrackingExample iotExample = new ImOrderTrackingExample();
		Criteria criteria = iotExample.createCriteria();
		if (null != imOrderTracking.getWorkorderId()) {
			criteria.andWorkorderIdEqualTo(imOrderTracking.getWorkorderId());
		}
		if (null != imOrderTracking.getEquipmentId()) {
			criteria.andEquipmentIdEqualTo(imOrderTracking.getEquipmentId());
		}
		
		if (null != imOrderTracking.getStartTime()) {
			criteria.andStartTimeEqualTo(imOrderTracking.getStartTime());
		}
		
		if (null != imOrderTracking.getEndTime()) {
			criteria.andEndTimeEqualTo(imOrderTracking.getEndTime());
		}
		
		if (null != imOrderTracking.getProcessNum()) {
			criteria.andProcessNumEqualTo(imOrderTracking.getProcessNum());
		}
		
		if (null != imOrderTracking.getPassNum()) {
			criteria.andPassNumEqualTo(imOrderTracking.getPassNum());
		}
		if (null != imOrderTracking.getWorkorderId()) {

		}
		iotMapper.insert(imOrderTracking);
		return null;
	}

	@Override
	public Result update(ImOrderTracking imOrderTracking) {

		iotMapper.updateByPrimaryKeySelective(imOrderTracking);
		return null;
	}

	@Override
	public Result delete(Long id) {
		iotMapper.deleteByPrimaryKey(id);
		return null;
	}

	@Override
	public Result findById(Long id) {
		ImOrderTracking orderTracking = iotMapper.selectByPrimaryKey(id);
		Result result = new Result(1,orderTracking,null);
		return result;
	}

	@Override
	public Result findByPage(int total, int page) {
		iotMapper.findByPage(total, page);
		
		return null;
	}

}
